#lang racket


(require "point.rkt")


(provide point<-vector<real>
         real<-number
         vector<real><-point
         vector<real><-list<number>
         vector<vector<real>><-list<point>
         list<vector<real>><-list<point>
         list<point><-vector<vector<real>>
         scale-matrix<-point)


(define (point<-vector<real> v)
  (xyz (vector-ref v 0)
         (vector-ref v 1)
         (vector-ref v 2)))

(define real<-number exact->inexact)

(define (vector<real><-point p)
  (vector-map real<-number (vector<-point p)))

(define (vector<real><-list<number> l)
  (list->vector (map real<-number l)))

(define (vector<vector<real>><-list<point> ps)
  (vector-map vector<real><-point (list->vector ps)))

(define (list<vector<real>><-list<point> ps)
  (map vector<real><-point ps))

(define (list<point><-vector<vector<real>> v)
  (map point<-vector<real> (vector->list v)))

(define (scale-matrix<-point p)
  (let ((x (real<-number (x p)))
        (y (real<-number (y p)))
        (z (real<-number (z p))))
    (vector x 0.0 0.0 0.0
            0.0 y 0.0 0.0
            0.0 0.0 z 0.0
            0.0 0.0 0.0 1.0)))